﻿using System.IO;
using System.Text.RegularExpressions;

namespace DiverseStudents.Resource.Public
{

    public enum ResType : uint
    {
        None = 0,
        Image = 1,
        Video = 2,
        Audio = 3,
        AB = 4,
    }

    public static class ResExtension
    {
        static readonly Regex imgFileRegex = new Regex("\\.(jpg|jpeg|png|gif|bmp|tiff|webp)$");
        static readonly Regex audioFileRegex = new Regex("\\.(mp3|wav|acc|flac|ogg|wma)$");
        static readonly Regex videoFileRegex = new Regex("\\.(mp4|avi|mov|mkv|flv|wmv)$");

        public static ResType GetFileType(string path)
        {
            var ext = Path.GetExtension(path).ToLower();
            if (imgFileRegex.IsMatch(ext))
            {
                return ResType.Image;
            }
            if (audioFileRegex.IsMatch(ext))
            {
                return ResType.Video;
            }
            if (videoFileRegex.IsMatch(ext))
            {
                return ResType.Audio;
            }
            if (ext == ".ab")
                return ResType.AB;
            return ResType.None;
        }
    }



}
